<template>
  <div>
      <el-row class="sort-bar">
        <el-col :span="6">
          <el-button-group>
            <el-button :class="'interview-num-' + sortType.InterviewDate" size="mini" @click="onSortByInterviewDate">注册日期<i
                            class="el-icon-caret-top asc"></i><i class="el-icon-caret-bottom desc"></i></el-button>
            <!-- <el-button :class="'interview-num-' + sortType.ShouSheDate" size="mini" @click="onShouSheDate">手设日期<i
                            class="el-icon-caret-top asc"></i><i class="el-icon-caret-bottom desc"></i></el-button>
            <el-button :class="'interview-num-' + sortType.CreateDate" size="mini" @click="onCreateDate">手设日期<i
                            class="el-icon-caret-top asc"></i><i class="el-icon-caret-bottom desc"></i></el-button> -->
            </el-button-group>
        </el-col>
        <el-col :span="12">
          <el-checkbox v-model="notSettime" @change="onInterTypeChange(1,notSettime)">有效</el-checkbox>
          <el-checkbox v-model="notStart" @change="onInterTypeChange(2,notStart)">失效</el-checkbox>
          <!-- <el-checkbox v-model="endNotSetinter" @change="onInterTypeChange(3,endNotSetinter)">设面试</el-checkbox>
          <el-checkbox v-model="setinterNotSetresult" @change="onInterTypeChange(4,setinterNotSetresult)">设结果</el-checkbox> -->
          
          <!-- <el-select v-model="otherType" placeholder="请选择-其它类" size="mini" style="margin-left:20px;width:150px;" @change="onInterTypeChange(5,otherType)">
            <el-option-group
              v-for="group in interviewType"
              :key="group.label"
              :label="group.label">
              <el-option
                v-for="item in group.options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-option-group>
          </el-select> -->
        </el-col>
        <el-col :span="6" class="text-right">
            <el-button type="primary" size="mini" @click="onAdd">登记</el-button>
            <el-button type="primary" size="mini" @click="onEdit">修改</el-button>
            <el-button type="primary" size="mini" @click="onDisable">失效</el-button>
            <el-button type="primary" size="mini" @click="onDel">删除</el-button>
        </el-col>
        <!-- <el-col :span="6" class="text-right">
          <el-pagination @current-change="onCurrentPageChange" :current-page="pageInfo.current_page" :page-size="pageInfo.size" layout="slot, total, prev, next, jumper"
            :total="pageInfo.total" class="newactli">
          </el-pagination>
        </el-col> -->
    </el-row>
  </div>
</template>

<script>
  export default {
    props: {
      pageInfo:{} //current_page,size,total
    },
    data(){
      return {
        bar_data:{ //返回上一级(index.vue)的
          'sort_by': 'interview_date', //排序字段  interview_date / shoushe_date / interview_order
          'sort_type': 'desc', //排序类型  desc / asc   

          'interview_type':'' //面试分类选项
        },
        sortByInterviewDate: true,
        sortByShouSheDate:false,
        sortCreateDate:false,
        sortType:{
          InterviewDate:'desc',
          ShouSheDate:'',
          CreateDate:''
        },

        notSettime:false,//预面试:'not_set_time'
        notStart:false,//未开始:'not_start'
        endNotSetinter:false,//设面试:'end_not_set_inter'
        setinterNotSetresult:false,//设结果:'setInter_not_setResult'

        otherType:'',
        interviewType:[{
          options: [{
            value: 'no_select',//未面试(面试时间过了，没举行面试的)
            label: '无'
          }]
        },{
          options: [{
            value: 'result_not_inter',//未面试(面试时间过了，没举行面试的)
            label: '未面试'
          }, {
            value: 'result_hav_inter',//已面试(录用、结果待定、未通过、设置下一轮面试)的
            label: '已面试'
          }, {
            value: 'cancel',//已取消
            label: '已取消'
          }, {
            value: 'last_inter',//过期面试
            label: '过期面试'
          }]
        }, {
          options: [{
            value: 'will_hire',//意向录用
            label: '意向录用'
          }, {
            value: 'pay_hire',//待付费录用
            label: '待付录用'
          }, {
            value: 'success_hire',//成功录用
            label: '成功录用'
          }, {
            value: 'invalid_hire',//无效录用
            label: '无效录用'
          }, {
            value: 'fail_hire',//失败录用
            label: '失败录用'
          }]
        }],
      };
    },
    methods: {
        onAdd(){
            this.$emit('add-user');
        },
        onEdit(){},
        onDisable(){},
        onDel(){},
        //--------------
      getButtonType(isSort) {
        return isSort === true ? 'success' : 'default';
      },
      //----------------------------------
      onSortByInterviewDate() {
        this.sortByInterviewDate = true;
        this.sortByShouSheDate=false;
        this.sortCreateDate=false;

        this.bar_data.sort_by='interview_date';

        if(this.sortType.InterviewDate=='desc'){
          this.sortType.InterviewDate='asc';
        }else{
          this.sortType.InterviewDate='desc';
        }        
        this.bar_data.sort_type=this.sortType.InterviewDate;
        this.sortType.ShouSheDate='';
        this.sortType.CreateDate='';

        this.$emit('click',this.bar_data);
      }, 
      onShouSheDate(){
        this.sortByInterviewDate = false;
        this.sortByShouSheDate=true;
        this.sortCreateDate=false;

        this.bar_data.sort_by='shoushe_date';

        if(this.sortType.ShouSheDate=='desc'){
          this.sortType.ShouSheDate='asc';
        }else{
          this.sortType.ShouSheDate='desc';
        }        
        this.bar_data.sort_type=this.sortType.ShouSheDate;
        this.sortType.InterviewDate='';
        this.sortType.CreateDate='';

        this.$emit('click',this.bar_data);        
      },
      onCreateDate(){
        this.sortByInterviewDate = false;
        this.sortByShouSheDate=false;
        this.sortCreateDate=true;

        this.bar_data.sort_by='create_date';
        
        if(this.sortType.CreateDate=='desc'){
          this.sortType.CreateDate='asc';
        }else{
          this.sortType.CreateDate='desc';
        }        
        this.bar_data.sort_type=this.sortType.CreateDate;
        this.sortType.InterviewDate='';        
        this.sortType.ShouSheDate='';  

        this.$emit('click',this.bar_data);         
      },
      //------------------------------------
      SetType(flag,val){
        //console.log(flag,val,(flag<5 && !val)||(flag==5 && val=='no_select'));
        if((flag<5 && !val)||(flag==5 && val=='no_select')){ //清队分类选项
          this.notSettime=false;//预面试
          this.notStart=false;//未开始
          this.endNotSetinter=false;//设面试
          this.setinterNotSetresult=false;//设结果
          this.otherType='';//其它面试类型     
          this.bar_data.interview_type=''; //查询项分类为空
        }
        switch(flag){
        case 1://预面试
          if(this.notSettime){
            this.notStart=false;//未开始
            this.endNotSetinter=false;//设面试
            this.setinterNotSetresult=false;//设结果
            this.otherType='';//其它面试类型
            this.bar_data.interview_type='not_set_time';
          }
          break;
        case 2://未开始
          if(this.notStart){
            this.notSettime=false;//预面试
            this.endNotSetinter=false;//设面试
            this.setinterNotSetresult=false;//设结果
            this.otherType='';//其它面试类型
            this.bar_data.interview_type='not_start';
          }
          break;
        case 3://设面试
          if(this.endNotSetinter){
            this.notSettime=false;//预面试
            this.notStart=false;//未开始
            this.setinterNotSetresult=false;//设结果
            this.otherType='';//其它面试类型
            this.bar_data.interview_type='end_not_set_inter';
          }
          break;
        case 4://设结果
          if(this.setinterNotSetresult){
            this.notSettime=false;//预面试
            this.notStart=false;//未开始
            this.endNotSetinter=false;//设面试
            this.otherType='';//其它面试类型
            this.bar_data.interview_type='setInter_not_setResult';
          }
          break;
        case 5://其它面试类型
          if(this.otherType!=''){
            this.notSettime=false;//预面试
            this.notStart=false;//未开始
            this.endNotSetinter=false;//设面试
            this.setinterNotSetresult=false;//设结果
            this.bar_data.interview_type=this.otherType;
          }
          break;
        }
      },
      onInterTypeChange(flag,val){//面试分类选项改变
        this.SetType(flag,val);
        this.$emit('click',this.bar_data);
      },

      onCurrentPageChange(currentPage){
        this.$emit('current-change',currentPage);
      }
    },    
  };
  </script>